Module main

File name: constants.py Author: Martin Jůda Python Version: 3.7 Description: Main app module that starts GUI and sets Rpi GPIO

Expand source code
"""
    File name: constants.py
    Author: Martin Jůda
    Python Version: 3.7
    Description: Main app module that starts GUI and sets Rpi GPIO
"""

import RPi.GPIO as GPIO

from modules.config import RELAY_OUTPUT_PIN
from modules.gui import GUI


def init_gpio():
    """Init Rpi GPIO pins and number layout"""
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup(RELAY_OUTPUT_PIN, GPIO.OUT)
    GPIO.output(RELAY_OUTPUT_PIN, GPIO.HIGH)


def main():
    """Start App"""
    init_gpio()  # Init Rpi GPIO
    try:
        app = GUI()
        app.attributes("-fullscreen", True)  # Start GUI in fullscreen mode
        app.mainloop()
    finally:
        GPIO.cleanup()  # Reset Rpi GPIO


if __name__ == "__main__":
    main()

Functions

def init_gpio()

Init Rpi GPIO pins and number layout

Expand source code
def init_gpio():
    """Init Rpi GPIO pins and number layout"""
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup(RELAY_OUTPUT_PIN, GPIO.OUT)
    GPIO.output(RELAY_OUTPUT_PIN, GPIO.HIGH)
def main()

Start App

Expand source code
def main():
    """Start App"""
    init_gpio()  # Init Rpi GPIO
    try:
        app = GUI()
        app.attributes("-fullscreen", True)  # Start GUI in fullscreen mode
        app.mainloop()
    finally:
        GPIO.cleanup()  # Reset Rpi GPIO